<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>

<%@include file="/common/head.jsp" %>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <p align="center"><font size="4" color="coral" face="楷体">员工基本信息</font></p>
    <form action="${ctx }/admin/employee/save?id=${n.id}"  class="form-horizontal" method="post">
        <div class="form-group">
            <input type="hidden" id="user-id" name="user.id" value="${n.user.id }" class="form-control">
            <input type="hidden" id="user-id-1" name="id" value="${n.id }" class="form-control">
            <!-- 用户ID -->
            <%--<label class="col-sm-2 control-label">用户ID</label>
            <div class="col-sm-4">

                <input type="text" id="user-id-1" name="id" value="${n.id }" class="form-control">
                <input type="text"  placeholder="请选择用户ID" class="form-control"  id="user-name" name="user.username" value="${n.user.id}"
                       onclick="bring({
                               url:'${ctx}/admin/user/search',
                               name: 'username',
                               idInput: 'user-id',
                               nameInput: 'user-name'
                               })" />

            </div>--%>

            <!-- 岗位 -->
            <label class="col-sm-2 control-label">岗位</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="position" value="${n.position }">
            </div>
        </div>
        <div class="form-group">

            <!-- 姓名 -->
            <label class="col-sm-2 control-label">姓名</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="name" value="${n.name }">
            </div>

            <!-- 出生日期 -->
            <label class="col-sm-2 control-label">出生日期</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="birth" value="<fmt:formatDate value='${n.birth }' pattern='yyyy-MM-dd'/>" onclick="laydate({format: 'YYYY-MM-DD'})">
            </div>
        </div>
        <div class="form-group">

            <!-- 性别 -->
            <label class="col-sm-2 control-label">性别</label>
            <div class="col-sm-4">
                <!-- <input type="text" class="form-control" name="sex" value="${n.sex }">-->
                <input type="radio" name="sex" value="1">男</input>
                <input type="radio" name="sex" value="0">女</input>
            </div>

            <!-- 身高 -->
            <label class="col-sm-2 control-label">身高</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="height" value="${n.height }">
            </div>
        </div>
        <div class="form-group">

            <!-- 体重 -->
            <label class="col-sm-2 control-label">体重</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="weight" value="${n.weight }">
            </div>

            <!-- 籍贯 -->
            <label class="col-sm-2 control-label">籍贯</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="place" value="${n.place }">
            </div>
        </div>
        <div class="form-group">

            <!-- 民族 -->
            <label class="col-sm-2 control-label">民族</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="nation" value="${n.nation }">
            </div>

            <!-- 联系电话 -->
            <label class="col-sm-2 control-label">联系电话</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="phone" value="${n.phone }">
            </div>
        </div>
        <div class="form-group">

            <!-- 身份证号 -->
            <label class="col-sm-2 control-label">身份证号</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="IDCard" value="${n.IDCard }">
            </div>

            <!-- 毕业学校 -->
            <label class="col-sm-2 control-label">毕业学校</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="school" value="${n.school }">
            </div>
        </div>
        <div class="form-group">

            <!-- 专业 -->
            <label class="col-sm-2 control-label">专业</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="major" value="${n.major }">
            </div>

            <!-- 学历 -->
            <label class="col-sm-2 control-label">学历</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="education" value="${n.education }">
            </div>
        </div>
        <div class="form-group">

            <!-- 户口所在地 -->
            <label class="col-sm-2 control-label">户口所在地</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="location" value="${n.location }">
            </div>

            <!-- 居住地址 -->
            <label class="col-sm-2 control-label">居住地址</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="address" value="${n.address }">
            </div>
        </div>
        <div class="form-group">

            <!-- 微信号 -->
            <label class="col-sm-2 control-label">微信号</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="wechat" value="${n.wechat }">
            </div>

            <!-- 邮箱 -->
            <label class="col-sm-2 control-label">邮箱</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="email" value="${n.email }">
            </div>
        </div>
        <div class="form-group">

            <!-- 婚姻状况 -->
            <label class="col-sm-2 control-label">婚姻状况</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="marry" value="${n.marry }">
            </div>

            <!-- 入职时间 -->
            <label class="col-sm-2 control-label">入职时间</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="in_time" value="<fmt:formatDate value='${n.inTime }' pattern='yyyy-MM-dd'/>" onclick="laydate({format: 'YYYY-MM-DD'})">
            </div>
        </div>
        <div class="form-group">

            <!-- 员工状态/1.录用/2.停职 -->
            <label class="col-sm-2 control-label">员工状态/1.录用/2.停职</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="status" value="${n.status }">
            </div>

        </div>
        <button type="button" class="sub-btn" >员工信息修改</button>
        <button type="button" class="btn btn-sm btn-outline btn-danger sub-btn-del" onclick="onDelete()"> <i class="fa fa-remove"></i>删除</button>


<!--紧急联系人信息-->
    <p align="center"><font size="4" color="coral" face="楷体">紧急联系人信息</font></p>

    <c:forEach items="${emergency}" var="em" varStatus="idx">

            <input type="hidden" id="employee-id1" name="employee.id" value="${em.employee.id }" class="form-control">
            <input type="hidden" id="user-id-2" name="emid" value="${em.emid }" class="form-control">
            <div class="form-group">
                <!-- 姓名 -->
                <label class="col-sm-2 control-label">姓名</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="emname" value="${em.emname }">
                </div>
                <!-- </div>

                 <div class="form-group">-->
                <!-- 关系 -->
                <label class="col-sm-2 control-label">关系</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="relation" value="${em.relation }">
                </div>
            </div>

            <div class="form-group">
                <!-- 联系电话 -->
                <label class="col-sm-2 control-label">联系电话</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="emphone" value="${em.emphone }">
                </div>
                <!--</div>
                <div class="form-group">-->
                <!-- 单位或住址 -->
                <label class="col-sm-2 control-label">单位或住址</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="emaddress" value="${em.emaddress }">
                </div>
            </div>
            <button type="button" class="sub-btn sub-btn-det" onclick="onDetailEm()">紧急联系人修改</button>
            <button type="button" class="btn btn-sm btn-outline btn-danger sub-btn-del" onclick="onDeleteEm()"> <i class="fa fa-remove"></i>删除</button>

    </c:forEach>




<!--教育经历-->

    <p align="center"><font size="4" color="coral" face="楷体">教育经历</font></p>
    <c:forEach items="${education }" var="n1" varStatus="idx">

            <input type="hidden" id="employee-id-1" name="employee.id" value="${n1.employee.id }" class="form-control">
            <input type="hidden" id="user-id-3" name="edid" value="${n1.edid }" class="form-control">
            <div class="form-group">
                <!-- 学习起始时间 -->
                <label class="col-sm-2 control-label">学习起始时间</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="start" value="<fmt:formatDate value='${n1.start }' pattern='yyyy-MM-dd'/>" onclick="laydate({format: 'YYYY-MM-DD'})">
                </div>
                <!--  </div>
                 <div class="form-group">-->
                <!-- 学习结束时间 -->
                <label class="col-sm-2 control-label">学习结束时间</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="end" value="<fmt:formatDate value='${n1.end }' pattern='yyyy-MM-dd'/>" onclick="laydate({format: 'YYYY-MM-DD'})">
                </div>
            </div>
            <div class="form-group">
                <!-- 专业 -->
                <label class="col-sm-2 control-label">专业</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="edmajor" value="${n1.edmajor }">
                </div>
                <!-- </div>
                 <div class="form-group">-->
                <!-- 学历 -->
                <label class="col-sm-2 control-label">学历</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="record" value="${n1.record }">
                </div>
            </div>
            <div class="form-group">
                <!-- 证书 -->
                <label class="col-sm-2 control-label">证书</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="certificate" value="${n1.certificate }">
                </div>
            </div>
            <button type="button" class="sub-btn sub-btn-det" onclick="onDetailEd()">教育经历修改</button>
            <button type="button" class="btn btn-sm btn-outline btn-danger sub-btn-del" onclick="onDeleteEd()"> <i class="fa fa-remove"></i>删除</button>

    </c:forEach>



<!--工作经历-->

    <p align="center"><font size="4" color="coral" face="楷体">工作经历</font></p>
    <c:forEach items="${experience}" var="ex" varStatus="idx">

            <input type="hidden" id="employee-id-2" name="employee.id" value="${ex.employee.id }" class="form-control">
            <input type="hidden" id="user-id-4" name="exid" value="${ex.exid }" class="form-control">
            <div class="form-group">
                <!-- 离职原因 -->
                <label class="col-sm-2 control-label">离职原因</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="reason" value="${ex.reason }">
                </div>


                <!-- 单位 -->
                <label class="col-sm-2 control-label">单位</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="company" value="${ex.company }">
                </div>
            </div>
            <div class="form-group">
                <!-- 工作 -->
                <label class="col-sm-2 control-label">工作</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="work" value="${ex.work }">
                </div>


                <!-- 职位 -->
                <label class="col-sm-2 control-label">职位</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="position1" value="${ex.position1 }">
                </div>
            </div>
            <div class="form-group">
                <!-- 工作起始时间 -->
                <label class="col-sm-2 control-label">工作起始时间</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="exstart" value="<fmt:formatDate value='${ex.exstart }' pattern='yyyy-MM-dd'/>" onclick="laydate({format: 'YYYY-MM-DD'})">
                </div>

                <!-- 工作结束时间 -->
                <label class="col-sm-2 control-label">工作结束时间</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="exend" value="<fmt:formatDate value='${ex.exend }' pattern='yyyy-MM-dd'/>" onclick="laydate({format: 'YYYY-MM-DD'})">
                </div>
            </div>
            <button type="button" class="sub-btn" >工作经历修改</button>
            <button type="button" class="btn btn-sm btn-outline btn-danger sub-btn-del" onclick="onDeleteEx()"> <i class="fa fa-remove"></i>删除</button>

    </c:forEach>



<!--家庭成员管理-->

    <p align="center"><font size="4" color="coral" face="楷体">家庭成员信息</font></p>
    <c:forEach items="${family }" var="fa" varStatus="idx">

            <input type="hidden" id="employee-id" name="employee.id" value="${fa.employee.id }" class="form-control">
            <input type="hidden" id="user-id-5" name="faid" value="${fa.faid }" class="form-control">
            <div class="form-group">
                <!-- 姓名 -->
                <label class="col-sm-2 control-label">姓名</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="faname" value="${fa.faname }">
                </div>

                <!-- 关系 -->
                <label class="col-sm-2 control-label">关系</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="farelation" value="${fa.farelation }">
                </div>
            </div>
            <div class="form-group">
                <!-- 联系方式 -->
                <label class="col-sm-2 control-label">联系方式</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="contact" value="${fa.contact }">
                </div>

                <!-- 年龄 -->
                <label class="col-sm-2 control-label">年龄</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="age" value="${fa.age }">
                </div>
            </div>
            <div class="form-group">

                <!-- 工作单位 -->
                <label class="col-sm-2 control-label">工作单位</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="facompany" value="${fa.facompany }">
                </div>


                <!-- 职位 -->
                <label class="col-sm-2 control-label">职位</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="position2" value="${fa.position2 }">
                </div>
            </div>
            <button type="button" class="sub-btn" >成员信息修改</button>
            <button type="button" class="btn btn-sm btn-outline btn-danger sub-btn-del" onclick="onDeletefa()"> <i class="fa fa-remove"></i>删除</button>

    </c:forEach>

    </form>
</div>
<%@include file="/common/foot.jsp" %>

<script>

    $(document).on("click", ".sub-btn", function () {
        var form = $(this).parents("form");
        form.ajaxSubmit({
            success: function(data) {
                if (isSuccess(data)) {
                    // reload();
                    location.reload()
                } else {
                }
            }
        });
    });

    $(document).on("click", ".sub-btn-del", function () {
        var form = $(this).parents("form");
        form.ajaxSubmit({
            success: function(data) {
                if (isSuccess(data)) {
                    //reload();
                    location.reload()

                } else {
                }
            }
        });
    });

    function onDelete(){
        var id =$("#user-id-1").val();
        var name = document.getElementById("user-id-1").value;
        location.href="${ctx}/admin/employee/delete?ids="+name;
    }

    function onDeleteEm(){
        var id =$("#user-id-2").val();
        var name = document.getElementById("user-id-2").value;
        location.href="${ctx}/admin/emergencyContact/delete?ids="+name;
    }

    function onDetailEm(){
        var id =$("#user-id-2").val();
        var name = document.getElementById("sub-btn-det").value;
        location.href="${ctx}/admin/emergencyContact/save1?ids="+name;
    }

    function onDeleteEd(){
        var id =$("#user-id-3").val();
        var name = document.getElementById("user-id-3").value;
        location.href="${ctx}/admin/education/delete?ids="+name;
    }

    function onDetailEd(){
        var id =$("#user-id-2").val();
        var name = document.getElementById("sub-btn-det").value;
        location.href="${ctx}/admin/education/save1?ids="+name;
    }

    function onDeleteEx(){
        var id =$("#user-id-4").val();
        var name = document.getElementById("user-id-4").value;
        location.href="${ctx}/admin/experience/delete?ids="+name;
    }

    function onDeletefa(){
        var id =$("#user-id-5").val();
        var name = document.getElementById("user-id-5").value;
        location.href="${ctx}/admin/family/delete?ids="+name;
    }
</script>
</body>
</html>